package com.heima.estatemanagement.service.impl;
import com.github.pagehelper.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.heima.estatemanagement.domain.TbHouse;
import com.heima.estatemanagement.domain.TbParking;
import com.heima.estatemanagement.service.TbHouseService;
import com.heima.estatemanagement.mapper.TbHouseMapper;
import com.sun.javafx.iio.ios.IosDescriptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;


/**
* @author Administrator
* @description 针对表【tb_house(房屋表)】的数据库操作Service实现
* @createDate 2023-02-01 14:42:45
*/
@Service
public class TbHouseServiceImpl implements TbHouseService{


    @Autowired
    public TbHouseMapper tbHouseMapper;



    @Override
    public List<TbHouse> findAll() {
        return tbHouseMapper.selectAll();
    }

    @Override
    public TbHouse findByNameAndById(int community_id) {
        return tbHouseMapper.finByCommunityId(community_id);
    }

    @Override
    public int add(TbHouse House) {

        return tbHouseMapper.add(House);
    }

    @Override
    public int update(TbHouse house) {
        return tbHouseMapper.update(house);
    }

    @Override
    public Page<TbHouse> search(Map searchMap) {
//        System.out.println("pageNum===>"+searchMap.get("pageNum"));
//        System.out.println("pageSize===>"+searchMap.get("pageSize"));
        Page<TbHouse> search = tbHouseMapper.search(searchMap);
        search.setTotal(tbHouseMapper.parkingCount(searchMap));

        return search;
    }

    @Override
    public Boolean delByIds(List<Integer> ids) {
       for (Integer id :ids){
           tbHouseMapper.deleteByPrimaryKey(id);
       }
        return false;
    }
    @Override
    public Boolean delById(int id) {
        return tbHouseMapper.delById(id);
    }


}




